from typing import List


class Solution:
    def minmaxGasDist(self, stations: List[int], k: int) -> float:
        distances = []
        for i in range(len(stations) - 1):
            distances.append(stations[i + 1] - stations[i])

        left, right = 0, max(distances)
        while right - left > pow(10, -7):
            mid = (left + right) / 2

            need = 0
            for distance in distances:
                a, b = divmod(distance, mid)
                need += (a - 1) + (1 if b > 0 else 0)

            if need <= k:
                right = mid
            else:
                left = mid

        return (left + right) / 2


if __name__ == "__main__":
    print(Solution().minmaxGasDist(stations=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k=9))  # # 0.500000
    print(Solution().minmaxGasDist(stations=[23, 24, 36, 39, 46, 56, 57, 65, 84, 98], k=1))  # 14.00000
